const fp = require("lodash/fp");
const { MayBe, Container } = require("./support");



// 1.
let maybe = MayBe.of([5,6,1]);
let ex1 = () => {
	// 你需要实现的函数
	return maybe.map((v) => v.map((item) => item + 1));
}

console.log(1, ex1());

// 2.
let xs = Container.of(["do", "ray", "me", "fa", "so", "la", "ti", "do"]);

let xs2 = () => {
  return xs._value;
};

console.log(2, fp.first(xs2()));


// 3.
let safeProp = fp.curry(function(x, o){
	return MayBe.of(o[x]);
})

let user = { id: 2, name: "Albert" }

let ex3 = () => {
  return safeProp("name", user).map((v) => fp.first(v))._value;
};

console.log(3, ex3());

// 4.
let ex4 = (n) => MayBe.of(n).map(v => parseInt(v))._value;
console.log(4, ex4("12"));